//token
const jwt  = require('jsonwebtoken');
let secret = 'I_LOVE_JING';
//生成token
exports.createToken =function(id){
    let payload = {id:id,time:new Date()};
    let token = jwt.sign(payload,secret,{expiresIn:60*60*24*20});
    return token;
}
//解密token
exports.verifyToken = function(token){
    let payload
    jwt.verify(token,secret,(err,result)=>{
        if(err){
            payload = 0
        }else{
            payload = 1
        }
    })
    return payload;
}